package com.example.pertecttime.base;

import android.content.Context;
import android.util.Log;

import com.example.pertecttime.R;
import com.example.pertecttime.tools.L;
import com.example.pertecttime.view.LoadingDialog;

/**
 * Created by 半生瓜 on 2017/7/17.
 */

public abstract class BasePresenter<M, V> {
    public Context context;
    public M modle;
    public V view;
    protected LoadingDialog dialog;
    public RxManager rxManager = new RxManager();


    public void onDestroy() {
        rxManager.clear();
    }

    public void setVM(Context context, V v, M m) {
        Log.d("test","setVM");
        this.context = context;
        this.view = v;
        this.modle = m;

    }

    protected void showLoadingDialog(Boolean isCanClose) {

        if (dialog == null) {
            dialog = new LoadingDialog(context, R.style.dialogBase);
            dialog.setCancelable(isCanClose);
            dialog.setTipText("加载中");
        }
        if (!dialog.isShowing()) {
            dialog.show();
        }
    }

    protected void hideLoadingDialog() {
        /*if(progressDialog != null && progressDialog.isShowing()){
            progressDialog.dismiss();
        }*/
        if (dialog != null && dialog.isShowing()) {
            L.d("关闭加载框");
            dialog.dismiss();
        }

    }


}
